package com.elysia.visionmanagerspringboot.controller;

import com.elysia.visionmanagerspringboot.domain.dto.PhotoDTO;
import com.elysia.visionmanagerspringboot.result.Result;
import com.elysia.visionmanagerspringboot.service.IPhotoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@RequestMapping("/photo")
@RequiredArgsConstructor
@Slf4j
public class PhotoController {
    private final IPhotoService photoService;
    @PostMapping("/upload")
    public Result<Object> upload(@ModelAttribute PhotoDTO photoDTO) throws IOException {
        log.info("上传图片{}", photoDTO);
        return photoService.update(photoDTO);
    }
    @GetMapping("/list")
    public Result<Object> list() {
        return photoService.getList();
    }
    @DeleteMapping("/{id}")
    public Result<Object> delete(@PathVariable Long id) {
        log.info("删除图片{}", id);
        return photoService.delete(id);
    }
}
